package com.ziyan.web;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hmall.common.dto.PageDTO;
import com.ziyan.pojo.ItemDoc;
import com.ziyan.pojo.RequestParam;
import com.ziyan.service.SearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/search")
@Slf4j
public class SearchController {

    @Autowired
    private SearchService searchService;

    @PostMapping("/filters")
    public Map<String, List<String>> filters(@RequestBody RequestParam requestPram) {
        Map<String,List<String>> map = searchService.filters(requestPram);
        return map;
    }

    @PostMapping("/list")
    public PageDTO<ItemDoc> list(@RequestBody RequestParam params) {
        log.info("普通搜索参数：{}",params);
        PageDTO<ItemDoc> pageDTO =  searchService.list(params);
        return pageDTO;
    }


}
